VERSION = 0.1.1-SNAPSHOT
SHAREDIR = $(DESTDIR)/usr/share/duplicatedetector
BINDIR = $(DESTDIR)/usr/bin

CC = mvn

all: package
	mv target/duplicatedetector-$(VERSION).jar target/duplicatedetector.jar

compile:
	$(CC) validate
	$(CC) compile

test: compile
	$(CC) test

package: test
	$(CC) package
	$(CC) integration-test
	$(CC) verify

install: all
	install -d $(SHAREDIR) $(BINDIR)
	install -m755 target/duplicatedetector.jar $(SHAREDIR)
	if [ -f target/duplicatedetector ]; then rm -f target/duplicatedetector; fi
	@echo "Generating exec script..."
	@echo "#!/bin/bash" >> target/duplicatedetector
	@echo -n "java -jar $(SHAREDIR)/duplicatedetector.jar" >> target/duplicatedetector
	@echo " -cp $(SHAREDIR):/usr/share/java/miglayout.jar" >> target/duplicatedetector
	install -m755 target/duplicatedetector $(BINDIR)

uninstall:
	rm -rf $(SHAREDIR)
	rm -f $(BINDIR)/duplicatedetector

clean:
	$(CC) clean
	if [ -d target ]; then rmdir target; fi